package lovely.gwt.json.client;

import com.google.gwt.json.client.JSONValue;
import lovely.gwt.json.client.JsonSerializable;


public abstract class JsonSerializer extends rocket.json.client.JsonSerializer {

	/**
	 * Deserializes the given jsonValue into a java object
	 * 
	 * @param jsonValue
	 * @return The deserialized read object.
	 */
	@Override
	abstract public Object readObject(JSONValue jsonValue);

	/**
	 * Serializes a java object into a jsonObject
	 * 
	 * @param instance
	 * @return A JSONValue holding the json form.
	 */
	@Override
	public JSONValue writeJson(Object instance) {
		return ((JsonSerializable) instance).toJson();
	}

}
